<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>购物车商品价格求和</title>
</head>
<body>
    <script>
        let book = {
            id:null,
            name: null,
            author: null,
            price: null
        }
        //购物车数组
        const shopArray = [
            {
                id:'01',
                name:'JSbook1',
                author: '盖伦',
                price: 50,
                num:2
                
            },
            {
                id:'02',
                name:'JSbook2',
                author: '剑姬',
                price: 60,
                num:3

            },
            {
                id:'03',
                name:'JSbook2',
                author: '剑圣',
                price: 70,
                num:1
            }
        ]
        let money=0;
        for(let i=0;i<shopArray.length;i++){
            money+=shopArray[i].price*shopArray[i].num;
            //console.log('money');
        }
        console.log('总价格：'+money);
    </script>
</body>
</html>